package behavior.chain_of_responsibility;
/**
 * 为请求创建了一个接收者对象的链
 * 通常每个接收者都包含对另一个接收者的引用
 */
public class ChainOfResponsibilityPatternDemo{
	
	/**责任链初始化*/
	public static LogManager getInitChain(){
		LogManager errorLog = new Error(LogManager.ERROR);
        LogManager infoLog = new Info(LogManager.INFO);
        LogManager debug = new Debug(LogManager.DEBUG);       

        errorLog.setNextLogManager(infoLog);
        infoLog.setNextLogManager(debug);       
        
		return errorLog;
	}

	public static void main(String[] args) {
		LogManager chain = getInitChain();
		
		chain.logManager(LogManager.ERROR, "error");		
		System.out.println("------------------");
		
		chain.logManager(LogManager.INFO, "info");
		System.out.println("------------------");
		
		chain.logManager(LogManager.DEBUG, "debug");
	}
	
}
